< previous page page_537 next page >

Page 537
In this code, you simply reference the data environment name, followed by the Connection object name, and then invoke the Open method on the Connection object. You then use the Command object as a property of the data environment to loop through all the last-name fields in the recordset. Notice that the data environment automatically creates a rs<CmdObjectName> property for you.
In the next example, you can create a new data environment object from the existing data environment object. This might be used if you needed to have two different connections to the same database:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdTest_Click()
   Dim deEmp As New denvEmployee

   deEmp.cnEmp.Open

   ' Do some processing
   With deEmp.rscmdEmployee
      .Open
      Do Until .EOF
         Debug.Print .Fields("szLast_nm")
         .MoveNext
      Loop
      .Close
   End With

   deEmp.cnEmp.Close
End Sub
In this code, you create a new instance of the data environment denvEmployee. This creates a new instance of the Connection object within that environment. You then apply the Open method to the new connection, and you now have a second connection to the data source.
Connecting to SQL Server
If you want to use SQL Server, youll get a different Connection tab in the Data Link Properties dialog box. In fact, every provider has a slightly different Connection tab because they each require different information to connect to their server. Figure 27.6 shows you the Connection tab for Microsoft SQL Server.

 
< previous page page_537 next page >

If you like this book, buy it!